<template>
  <el-upload
    class="upload-demo"
    drag
    action="https://backend.dragonmate.hhzy.fun:444/common/uploadfile"
    multiple
    :limit="1"
    :file-list="fileList"
    :on-success="handleSuccess"
  >
    <i class="el-icon-upload" />
    <div class="el-upload__text">
      将文件拖到此处，或
      <em>点击上传</em>
    </div>
  </el-upload>
</template>

<script>
export default {
  name: 'DragUpload',
  data() {
    return {
      fileList: []
    }
  },
  methods: {
    handleSuccess(file) {
      if (!file.code) {
        console.log(this.fileList)
        console.log(file)
        this.$emit('handleSuccess', file.url)
        this.$message(
          {
            message: '文件上传成功',
            type: 'success'
          })
      } else {
        this.$message({
          message: '文件上传失败',
          type: 'error'
        })
      }
    }
  }
}
</script>

<style scoped>

</style>
